package GUI;
import java.util.Calendar;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JTextField;

class AlarmPopUp extends Thread implements Runnable {

	private long alarmzeit;
        private String beschreibung_text;

	public AlarmPopUp(long alarm, String alarm_bezeichnung) {
		this.alarmzeit = alarm;
                this.beschreibung_text = alarm_bezeichnung;
	}

    @Override
	public void run() {
		Calendar cal = Calendar.getInstance();
		cal.setTimeInMillis(alarmzeit);
		java.util.Date date = cal.getTime();

		JDialog dialog = new JDialog();
		JLabel text = new JLabel("<html><font size=+2>Alarm: " + beschreibung_text + "<br>" + date + "</font></html>");
		dialog.add(text);
		dialog.setTitle("Alarm");
		dialog.setBounds(200, 200, 400, 200);
		dialog.setVisible(false);
                dialog.setAlwaysOnTop(true);
                
		try {

			while (System.currentTimeMillis() <= alarmzeit) {
				sleep(1000);
			}

			dialog.setVisible(true);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}

	
}